package com.example.springsession.springbean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.stereotype.Component;

/**
 * Created by x on 2020/7/25 0025.
 * bean后置处理__BeanDefinition 修改
 * bean定义--》get(bean)-->bean实例放入单例缓存池
 */
@Component
public class BeanPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        GenericBeanDefinition helloCo= (GenericBeanDefinition) beanFactory.getBeanDefinition("helloCo");
        System.out.println(helloCo);
//        helloCo.setBeanClass();
        helloCo.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME); // 注入模型
//        helloCo.setDependsOn();
//        helloCo.setLazyInit();
//        helloCo.setConstructorArgumentValues();
    }
}
